<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/11/22 15:27
 */

namespace App\Project\Search\Decorator;

use App\Project\Search\Decorator;

class MedicalDecorator extends Decorator
{
    protected $table = 'st_medical_records';

    protected $prefix = 'medical';

    /**
     * @return \Illuminate\Database\Query\Builder
     */
    public function getBuilder()
    {
        foreach ($this->condition as $field => $condition) {

            if ($this->reject($field, $condition['operator'])) {
                continue;
            }

            $this->db->whereRaw(...$this->condition($condition, $field));
        }

        return $this->db;
    }

    public function getAccessField()
    {
        return ['id' => 'id', 'clinic_at' => 'clinic_at'];
    }

    public function getAccessOperator()
    {
        return [
            'id' => ['in'], 'clinic_at' => 'all',
        ];
    }
}